<?php
/**
 *
 * @author griever
 * @version 
 */
require_once 'Base.php';

/**
 * SendCookies Action Helper 
 * 
 * @uses actionHelper Custom_Helper
 */
class Custom_Helper_SendCookies extends Dummy_Helper_Base {
	
	public function sendCookies($cookieJar)	{
		$cookies = $cookieJar->getAllCookies(Zend_Http_CookieJar::COOKIE_OBJECT);
		foreach ($cookies as $cookie) {
			$result = setcookie($cookie->getName(), $cookie->getValue(), $cookie->getExpiryTime(), '/');
			if (!$result)
				throw new Zend_Exception("cannot send cookie");
		}
	}
	
	/**
	 * Strategy pattern: call helper as broker method
	 */
	public function direct($cookieJar) {
		// TODO Auto-generated 'direct' method
		return $this->sendCookies($cookieJar);
	}
}
